package com.xquant.common.engine.xPP.response;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xquant.common.engine.utils.SysUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Contract {
    @JSONField(ordinal = 1)
    private String npv;
    @JSONField(ordinal = 2)
    private String rho;
    @JSONField(ordinal = 3)
    private String theta;
    @JSONField(ordinal = 4)
    private String delta;
    @JSONField(ordinal = 5)
    private List<UnderlyerValue> deltas;
    @JSONField(ordinal = 6)
    private String deltaForward;
    @JSONField(ordinal = 7)
    private String vega;
    @JSONField(ordinal = 8)
    private List<UnderlyerValue> vegas;
    @JSONField(ordinal = 9)
    private String gamma;
    @JSONField(ordinal = 10)
    private RectangularCoordinates gammas;
    @JSONField(ordinal = 11)
    private String gammaForward;
    @JSONField(ordinal = 12)
    private String vanna;
    @JSONField(ordinal = 13)
    private RectangularCoordinates vannas;
    @JSONField(ordinal = 14)
    private String volga;
    @JSONField(ordinal = 15)
    private RectangularCoordinates volgas;
    @JSONField(ordinal = 16)
    private String dvbp;
    @JSONField(ordinal = 17)
    private String premiumNpv;
    @JSONField(ordinal = 18)
    private String spotPrice;
    @JSONField(ordinal = 19)
    private String dscRate;
    @JSONField(ordinal = 20)
    private String fundRate;
    @JSONField(ordinal = 21)
    private String divRate;
    @JSONField(ordinal = 22)
    private String volRate;
    @JSONField(ordinal = 23)
    private String fxVolRate;
    @JSONField(ordinal = 24)
    private String corr;
    @JSONField(ordinal = 25)
    private String fxRate;
    @JSONField(ordinal = 26)
    private String numberOfOptions;
    @JSONField(ordinal = 27)
    private String optionEntitlement;
    @JSONField(ordinal = 28)
    private String cashdelta;
    @JSONField(ordinal = 29)
    private String cashdelta1percent;
    @JSONField(ordinal = 30)
    private String cashgamma;
    @JSONField(ordinal = 31)
    private String cashgamma1percent;
    @JSONField(ordinal = 32)
    private String strikePrice;
    @JSONField(ordinal = 33)
    private String strikeYield;
    @JSONField(ordinal = 34)
    private String strikeDuration;
    @JSONField(ordinal = 35)
    private String productType;
    @JSONField(ordinal = 36)
    private String fairRate;
    @JSONField(ordinal = 37)
    private List<String> krDvbps;
    @JSONField(ordinal = 38)
    private String accrual0;
    @JSONField(ordinal = 39)
    private String accrual1;

    //国债期货
    @JSONField(ordinal = 40)
    private String remainNotional;
    @JSONField(ordinal = 41)
    private String multiplier;
    @JSONField(ordinal = 42)
    private String remainTerm;
    @JSONField(ordinal = 43)
    private String expired;
    @JSONField(ordinal = 44)
    private String dscCurveCode;
    @JSONField(ordinal = 45)
    private String sType;
    @JSONField(ordinal = 46)
    private String marketNPV;
    @JSONField(ordinal = 47)
    private String unOffsetVolume;
    @JSONField(ordinal = 48)
    private String irr;
    @JSONField(ordinal = 49)
    private String basis;
    @JSONField(ordinal = 50)
    private String bnoc;
    @JSONField(ordinal = 51)
    private String cf;
    @JSONField(ordinal = 52)
    private String cfSource;
    @JSONField(ordinal = 53)
    private String invoicePrice;
    @JSONField(ordinal = 54)
    private String remainDays;
    @JSONField(ordinal = 55)
    private String income;
    @JSONField(ordinal = 56)
    private String cost;
    @JSONField(ordinal = 57)
    private String carry;

    //利率互换
    @JSONField(ordinal = 58)
    private String ad;
    @JSONField(ordinal = 59)
    private List<String> contribution;
    @JSONField(ordinal = 60)
    private List<String> kd;

    //债券
    @JSONField(ordinal = 61)
    private String cmarketNPV;
    @JSONField(ordinal = 62)
    private String ytm;
    @JSONField(ordinal = 63)
    private String md;
    @JSONField(ordinal = 64)
    private String cv;
    @JSONField(ordinal = 65)
    private String actualRate;
    @JSONField(ordinal = 66)
    private String durationBench;
    @JSONField(ordinal = 67)
    private String durationSpread;
    @JSONField(ordinal = 68)
    private String convexityBench;
    @JSONField(ordinal = 69)
    private String convexitySpread;
    @JSONField(ordinal = 70)
    private String shortDuration;
    @JSONField(ordinal = 71)
    private String shortRemainTerm;

    //信用互换
    private String creditDvbp; // 信用DVBP(平移1bp曲线) 违约曲线上下偏移1BP
    private String cs01; // 信用利差变动对合约估值的影响(Credit Spread DV01)（平移报价）违约曲线使用upRate
    private String eprice; // 估值价格
    private String epriceNet; // 估值价格净价
    private String epriceType; // ModeNPV:模型估值
    private String mtrDate; // 到期日
    private String riskyDvbp; // 保护费率的敏感度
    private String tpriceNet; // 理论价格(净价)
    private String tpriceFee; // 费用端估值
    private String tpricePro;// 保护端估值


    //商品远期
    private String forwardPrice; // 远期价格
    private String domesticDvbp; // 贴现融资曲线变动
    private String foreignDvbp; // 红利曲线变动
    private String dscDvbp; // 贴现曲线变动

    public String getNpv() {

        return SysUtils.isVoid(npv) ? "0" : npv;
    }

    public String getRho() {

        return SysUtils.isVoid(rho) ? "0" : rho;
    }

    public String getTheta() {
        return SysUtils.isVoid(theta) ? "0" : theta;
    }

    public String getDelta() {
        return SysUtils.isVoid(delta) ? "0" : delta;
    }

    public List<UnderlyerValue> getDeltas() {
        return deltas;
    }

    public String getDeltaForward() {
        return deltaForward;
    }

    public String getVega() {
        return SysUtils.isVoid(vega) ? "0" : vega;
    }

    public List<UnderlyerValue> getVegas() {
        return vegas;
    }

    public String getGamma() {
        return SysUtils.isVoid(gamma) ? "0" : gamma;
    }

    public RectangularCoordinates getGammas() {
        return gammas;
    }

    public String getGammaForward() {
        return SysUtils.isVoid(gammaForward) ? "0" : gammaForward;
    }

    public String getVanna() {
        return vanna;
    }

    public RectangularCoordinates getVannas() {
        return vannas;
    }

    public String getVolga() {
        return volga;
    }

    public RectangularCoordinates getVolgas() {
        return volgas;
    }

    public String getDvbp() {
        return dvbp;
    }

    public String getPremiumNpv() {
        return premiumNpv;
    }

    public String getSpotPrice() {
        return SysUtils.isVoid(spotPrice) ? "0" : spotPrice;
    }

    public String getDscRate() {
        return dscRate;
    }

    public String getFundRate() {
        return fundRate;
    }

    public String getDivRate() {
        return divRate;
    }

    public String getVolRate() {
        return volRate;
    }

    public String getFxVolRate() {
        return fxVolRate;
    }

    public String getCorr() {
        return corr;
    }

    public String getFxRate() {
        return fxRate;
    }

    public String getNumberOfOptions() {
        return numberOfOptions;
    }

    public String getOptionEntitlement() {
        return optionEntitlement;
    }

    public String getCashdelta() {
        return cashdelta;
    }

    public String getCashdelta1percent() {
        return cashdelta1percent;
    }

    public String getCashgamma() {
        return cashgamma;
    }

    public String getCashgamma1percent() {
        return cashgamma1percent;
    }

    public String getStrikePrice() {
        return strikePrice;
    }

    public String getStrikeYield() {
        return strikeYield;
    }

    public String getStrikeDuration() {
        return strikeDuration;
    }

    public String getProductType() {
        return productType;
    }

    public String getFairRate() {
        return fairRate;
    }

    public List<String> getKrDvbps() {
        return krDvbps;
    }

    public String getAccrual0() {
        return accrual0;
    }

    public String getAccrual1() {
        return accrual1;
    }

    public String getRemainNotional() {
        return remainNotional;
    }

    public String getMultiplier() {
        return multiplier;
    }

    public String getRemainTerm() {
        return remainTerm;
    }

    public String getExpired() {
        return expired;
    }

    public String getDscCurveCode() {
        return dscCurveCode;
    }

    public String getsType() {
        return sType;
    }

    public String getMarketNPV() {
        return marketNPV;
    }

    public String getUnOffsetVolume() {
        return unOffsetVolume;
    }

    public String getIrr() {
        return irr;
    }

    public String getBasis() {
        return basis;
    }

    public String getBnoc() {
        return bnoc;
    }

    public String getCf() {
        return cf;
    }

    public String getCfSource() {
        return cfSource;
    }

    public String getInvoicePrice() {
        return invoicePrice;
    }

    public String getRemainDays() {
        return remainDays;
    }

    public String getIncome() {
        return income;
    }

    public String getCost() {
        return cost;
    }

    public String getCarry() {
        return carry;
    }

    public String getAd() {
        return ad;
    }

    public List<String> getContribution() {
        return contribution;
    }

    public List<String> getKd() {
        return kd;
    }

    public String getCmarketNPV() {
        return cmarketNPV;
    }

    public String getYtm() {
        return ytm;
    }

    public String getMd() {
        return md;
    }

    public String getCv() {
        return cv;
    }

    public String getActualRate() {
        return actualRate;
    }

    public String getDurationBench() {
        return durationBench;
    }

    public String getDurationSpread() {
        return durationSpread;
    }

    public String getConvexityBench() {
        return convexityBench;
    }

    public String getConvexitySpread() {
        return convexitySpread;
    }

    public String getShortDuration() {
        return shortDuration;
    }

    public String getShortRemainTerm() {
        return shortRemainTerm;
    }

    public String getCreditDvbp() {
        return creditDvbp;
    }

    public String getCs01() {
        return cs01;
    }

    public String getEprice() {
        return eprice;
    }

    public String getEpriceNet() {
        return epriceNet;
    }

    public String getEpriceType() {
        return epriceType;
    }

    public String getMtrDate() {
        return mtrDate;
    }

    public String getRiskyDvbp() {
        return riskyDvbp;
    }

    public String getTpriceNet() {
        return tpriceNet;
    }

    public String getTpriceFee() {
        return tpriceFee;
    }

    public String getTpricePro() {
        return tpricePro;
    }

    public String getForwardPrice() {
        return forwardPrice;
    }

    public String getDomesticDvbp() {
        return domesticDvbp;
    }

    public String getForeignDvbp() {
        return foreignDvbp;
    }

    public String getDscDvbp() {
        return dscDvbp;
    }

    public void setNpv(String npv) {
        if (npv != null) {
            this.npv = npv;
        }
    }

    public void setRho(String rho) {
        if (rho != null) {
            this.rho = rho;
        }
    }

    public void setTheta(String theta) {
        if (theta != null) {
            this.theta = theta;
        }
    }

    public void setDelta(String delta) {
        if (delta != null) {
            this.delta = delta;
        }
    }

    public void setDeltas(List<UnderlyerValue> deltas) {
        this.deltas = deltas;
    }

    public void setDeltaForward(String deltaForward) {
        if (deltaForward != null) {
            this.deltaForward = deltaForward;
        }
    }

    public void setVega(String vega) {
        if (vega != null) {
            this.vega = vega;
        }
    }

    public void setVegas(List<UnderlyerValue> vegas) {
        this.vegas = vegas;
    }

    public void setGamma(String gamma) {
        if (gamma != null) {
            this.gamma = gamma;
        }
    }

    public void setGammas(RectangularCoordinates gammas) {
        this.gammas = gammas;
    }

    public void setGammaForward(String gammaForward) {
        if (gammaForward != null) {
            this.gammaForward = gammaForward;
        }
    }

    public void setVanna(String vanna) {
        if (vanna != null) {
            this.vanna = vanna;
        }
    }

    public void setVannas(RectangularCoordinates vannas) {
        this.vannas = vannas;
    }

    public void setVolga(String volga) {
        if (volga != null) {
            this.volga = volga;
        }
    }

    public void setVolgas(RectangularCoordinates volgas) {
        this.volgas = volgas;
    }

    public void setDvbp(String dvbp) {
        if (dvbp != null) {
            this.dvbp = dvbp;
        }
    }

    public void setPremiumNpv(String premiumNpv) {
        if (premiumNpv != null) {
            this.premiumNpv = premiumNpv;
        }
    }

    public void setSpotPrice(String spotPrice) {
        if (spotPrice != null) {
            this.spotPrice = spotPrice;
        }
    }

    public void setDscRate(String dscRate) {
        if (dscRate != null) {
            this.dscRate = dscRate;
        }
    }

    public void setFundRate(String fundRate) {
        if (fundRate != null) {
            this.fundRate = fundRate;
        }
    }

    public void setDivRate(String divRate) {
        if (divRate != null) {
            this.divRate = divRate;
        }
    }

    public void setVolRate(String volRate) {
        if (volRate != null) {
            this.volRate = volRate;
        }
    }

    public void setFxVolRate(String fxVolRate) {
        if (fxVolRate != null) {
            this.fxVolRate = fxVolRate;
        }
    }

    public void setCorr(String corr) {
        if (corr != null) {
            this.corr = corr;
        }
    }

    public void setFxRate(String fxRate) {
        if (fxRate != null) {
            this.fxRate = fxRate;
        }
    }

    public void setNumberOfOptions(String numberOfOptions) {
        if (numberOfOptions != null) {
            this.numberOfOptions = numberOfOptions;
        }
    }

    public void setOptionEntitlement(String optionEntitlement) {
        if (optionEntitlement != null) {
            this.optionEntitlement = optionEntitlement;
        }
    }

    public void setCashdelta(String cashdelta) {
        if (cashdelta != null) {
            this.cashdelta = cashdelta;
        }
    }

    public void setCashdelta1percent(String cashdelta1percent) {
        if (cashdelta1percent != null) {
            this.cashdelta1percent = cashdelta1percent;
        }
    }

    public void setCashgamma(String cashgamma) {
        if (cashgamma != null) {
            this.cashgamma = cashgamma;
        }
    }

    public void setCashgamma1percent(String cashgamma1percent) {
        if (cashgamma1percent != null) {
            this.cashgamma1percent = cashgamma1percent;
        }
    }

    public void setStrikePrice(String strikePrice) {
        if (strikePrice != null) {
            this.strikePrice = strikePrice;
        }
    }

    public void setStrikeYield(String strikeYield) {
        if (strikeYield != null) {
            this.strikeYield = strikeYield;
        }
    }

    public void setStrikeDuration(String strikeDuration) {
        if (strikeDuration != null) {
            this.strikeDuration = strikeDuration;
        }
    }

    public void setProductType(String productType) {
        if (productType != null) {
            this.productType = productType;
        }
    }

    public void setFairRate(String fairRate) {
        if (fairRate != null) {
            this.fairRate = fairRate;
        }
    }

    public void setKrDvbps(List<String> krDvbps) {
        this.krDvbps = krDvbps;
    }

    public void setAccrual0(String accrual0) {
        if (accrual0 != null) {
            this.accrual0 = accrual0;
        }
    }

    public void setAccrual1(String accrual1) {
        if (accrual1 != null) {
            this.accrual1 = accrual1;
        }
    }

    public void setRemainNotional(String remainNotional) {
        if (remainNotional != null) {
            this.remainNotional = remainNotional;
        }
    }

    public void setMultiplier(String multiplier) {
        if (multiplier != null) {
            this.multiplier = multiplier;
        }
    }

    public void setRemainTerm(String remainTerm) {
        if (remainTerm != null) {
            this.remainTerm = remainTerm;
        }
    }

    public void setExpired(String expired) {
        if (expired != null) {
            this.expired = expired;
        }
    }

    public void setDscCurveCode(String dscCurveCode) {
        if (dscCurveCode != null) {
            this.dscCurveCode = dscCurveCode;
        }
    }

    public void setsType(String sType) {
        if (sType != null) {
            this.sType = sType;
        }
    }

    public void setMarketNPV(String marketNPV) {
        if (marketNPV != null) {
            this.marketNPV = marketNPV;
        }
    }

    public void setUnOffsetVolume(String unOffsetVolume) {
        if (unOffsetVolume != null) {
            this.unOffsetVolume = unOffsetVolume;
        }
    }

    public void setIrr(String irr) {
        if (irr != null) {
            this.irr = irr;
        }
    }

    public void setBasis(String basis) {
        if (basis != null) {
            this.basis = basis;
        }
    }

    public void setBnoc(String bnoc) {
        if (bnoc != null) {
            this.bnoc = bnoc;
        }
    }

    public void setCf(String cf) {
        if (cf != null) {
            this.cf = cf;
        }
    }

    public void setCfSource(String cfSource) {
        if (cfSource != null) {
            this.cfSource = cfSource;
        }
    }

    public void setInvoicePrice(String invoicePrice) {
        if (invoicePrice != null) {
            this.invoicePrice = invoicePrice;
        }
    }

    public void setRemainDays(String remainDays) {
        if (remainDays != null) {
            this.remainDays = remainDays;
        }
    }

    public void setIncome(String income) {
        if (income != null) {
            this.income = income;
        }
    }

    public void setCost(String cost) {
        if (cost != null) {
            this.cost = cost;
        }
    }

    public void setCarry(String carry) {
        if (carry != null) {
            this.carry = carry;
        }
    }

    public void setAd(String ad) {
        if (ad != null) {
            this.ad = ad;
        }
    }

    public void setContribution(List<String> contribution) {
        this.contribution = contribution;
    }

    public void setKd(List<String> kd) {
        this.kd = kd;
    }

    public void setCmarketNPV(String cmarketNPV) {
        if (cmarketNPV != null) {
            this.cmarketNPV = cmarketNPV;
        }
    }

    public void setYtm(String ytm) {
        if (ytm != null) {
            this.ytm = ytm;
        }
    }

    public void setMd(String md) {
        if (md != null) {
            this.md = md;
        }
    }

    public void setCv(String cv) {
        if (cv != null) {
            this.cv = cv;
        }
    }

    public void setActualRate(String actualRate) {
        if (actualRate != null) {
            this.actualRate = actualRate;
        }
    }

    public void setDurationBench(String durationBench) {
        if (durationBench != null) {
            this.durationBench = durationBench;
        }
    }

    public void setDurationSpread(String durationSpread) {
        if (durationSpread != null) {
            this.durationSpread = durationSpread;
        }
    }

    public void setConvexityBench(String convexityBench) {
        if (convexityBench != null) {
            this.convexityBench = convexityBench;
        }
    }

    public void setConvexitySpread(String convexitySpread) {
        if (convexitySpread != null) {
            this.convexitySpread = convexitySpread;
        }
    }

    public void setShortDuration(String shortDuration) {
        if (shortDuration != null) {
            this.shortDuration = shortDuration;
        }
    }

    public void setShortRemainTerm(String shortRemainTerm) {
        if (shortRemainTerm != null) {
            this.shortRemainTerm = shortRemainTerm;
        }
    }

    public void setCreditDvbp(String creditDvbp) {
        if (creditDvbp != null) {
            this.creditDvbp = creditDvbp;
        }
    }

    public void setCs01(String cs01) {
        if (cs01 != null) {
            this.cs01 = cs01;
        }
    }

    public void setEprice(String eprice) {
        if (eprice != null) {
            this.eprice = eprice;
        }
    }

    public void setEpriceNet(String epriceNet) {
        if (epriceNet != null) {
            this.epriceNet = epriceNet;
        }
    }

    public void setEpriceType(String epriceType) {
        if (epriceType != null) {
            this.epriceType = epriceType;
        }
    }

    public void setMtrDate(String mtrDate) {
        if (mtrDate != null) {
            this.mtrDate = mtrDate;
        }
    }

    public void setRiskyDvbp(String riskyDvbp) {
        if (riskyDvbp != null) {
            this.riskyDvbp = riskyDvbp;
        }
    }

    public void setTpriceNet(String tpriceNet) {
        if (tpriceNet != null) {
            this.tpriceNet = tpriceNet;
        }
    }

    public void setTpriceFee(String tpriceFee) {
        if (tpriceFee != null) {
            this.tpriceFee = tpriceFee;
        }
    }

    public void setTpricePro(String tpricePro) {
        if (tpricePro != null) {
            this.tpricePro = tpricePro;
        }
    }

    public void setForwardPrice(String forwardPrice) {
        if (forwardPrice != null) {
            this.forwardPrice = forwardPrice;
        }
    }

    public void setDomesticDvbp(String domesticDvbp) {
        if (domesticDvbp != null) {
            this.domesticDvbp = domesticDvbp;
        }
    }

    public void setForeignDvbp(String foreignDvbp) {
        if (foreignDvbp != null) {
            this.foreignDvbp = foreignDvbp;
        }
    }

    public void setDscDvbp(String dscDvbp) {
        if (dscDvbp != null) {
            this.dscDvbp = dscDvbp;
        }
    }

    public void merge(Contract contract) {
        if (contract == null) {
            return;
        }
        this.setSpotPrice(contract.getSpotPrice());
        String dscRate = contract.getDscRate();
        this.setDscRate(dscRate);
        this.setFundRate(contract.getFundRate());
        this.setDivRate(contract.getDivRate());
        this.setVolRate(contract.getVolRate());
        this.setFxVolRate(contract.getFxVolRate());
        this.setCorr(contract.getCorr());
        this.setFxRate(contract.getFxRate());
        String npv = contract.getNpv();
        if (npv != null) {
            this.npv = String.valueOf(this.npv == null ? BigDecimal.ZERO.add(new BigDecimal(npv)) : new BigDecimal(this.npv).add(new BigDecimal(npv)));
        }

        String rho = contract.getRho();
        if (rho != null) {
            this.rho = String.valueOf(this.rho == null ? BigDecimal.ZERO.add(new BigDecimal(rho)) : new BigDecimal(this.rho).add(new BigDecimal(rho)));
        }

        String theta = contract.getTheta();
        if (theta != null) {
            this.theta = String.valueOf(this.theta == null ? BigDecimal.ZERO.add(new BigDecimal(theta)) : new BigDecimal(this.theta).add(new BigDecimal(theta)));
        }
        String delta = contract.getDelta();
        if (delta != null) {
            this.delta = String.valueOf(this.delta == null ? BigDecimal.ZERO.add(new BigDecimal(delta)) : new BigDecimal(this.delta).add(new BigDecimal(delta)));
        }

        String deltaForward = contract.getDeltaForward();
        if (deltaForward != null) {
            this.deltaForward = String.valueOf(this.deltaForward == null ? BigDecimal.ZERO.add(new BigDecimal(deltaForward)) : new BigDecimal(this.deltaForward).add(new BigDecimal(deltaForward)));
        }

        String vega = contract.getVega();
        if (vega != null) {
            this.vega = String.valueOf(this.vega == null ? BigDecimal.ZERO.add(new BigDecimal(vega)) : new BigDecimal(this.vega).add(new BigDecimal(vega)));
        }

        String gamma = contract.getGamma();
        if (gamma != null) {
            this.gamma = String.valueOf(this.gamma == null ? BigDecimal.ZERO.add(new BigDecimal(gamma)) : new BigDecimal(this.gamma).add(new BigDecimal(gamma)));
        }

        String gammaForward = contract.getGammaForward();
        if (gammaForward != null) {
            this.gammaForward = String.valueOf(this.gammaForward == null ? BigDecimal.ZERO.add(new BigDecimal(gammaForward)) : new BigDecimal(this.gammaForward).add(new BigDecimal(gammaForward)));
        }

        String vanna = contract.getVanna();
        if (vanna != null) {
            this.vanna = String.valueOf(this.vanna == null ? BigDecimal.ZERO.add(new BigDecimal(vanna)) : new BigDecimal(this.vanna).add(new BigDecimal(vanna)));
        }

        String volga = contract.getVolga();
        if (vanna != null) {
            this.volga = String.valueOf(this.volga == null ? BigDecimal.ZERO.add(new BigDecimal(volga)) : new BigDecimal(this.volga).add(new BigDecimal(volga)));
        }

        String dvbp = contract.getDvbp();
        if (dvbp != null) {
            this.dvbp = String.valueOf(this.dvbp == null ? BigDecimal.ZERO.add(new BigDecimal(dvbp)) : new BigDecimal(this.dvbp).add(new BigDecimal(dvbp)));
        }

        String cashdelta = contract.getCashdelta();
        if (cashdelta != null) {
            this.cashdelta = String.valueOf(this.cashdelta == null ? BigDecimal.ZERO.add(new BigDecimal(cashdelta)) : new BigDecimal(this.cashdelta).add(new BigDecimal(cashdelta)));
        }

        String cashdelta1percent = contract.getCashdelta1percent();
        if (cashdelta1percent != null) {
            this.cashdelta1percent = String.valueOf(this.cashdelta1percent == null ? BigDecimal.ZERO.add(new BigDecimal(cashdelta1percent)) : new BigDecimal(this.cashdelta1percent).add(new BigDecimal(cashdelta1percent)));
        }

        String cashgamma = contract.getCashgamma();
        if (cashgamma != null) {
            this.cashgamma = String.valueOf(this.cashgamma == null ? BigDecimal.ZERO.add(new BigDecimal(cashgamma)) : new BigDecimal(this.cashgamma).add(new BigDecimal(cashgamma)));
        }

        String cashgamma1percent = contract.getCashgamma1percent();
        if (cashgamma1percent != null) {
            this.cashgamma1percent = String.valueOf(this.cashgamma1percent == null ? BigDecimal.ZERO.add(new BigDecimal(cashgamma1percent)) : new BigDecimal(this.cashgamma1percent).add(new BigDecimal(cashgamma1percent)));
        }

        List<UnderlyerValue> deltas = contract.getDeltas();
        if (deltas != null && deltas.size() > 0) {
            for (UnderlyerValue underlyerValue : deltas) {
                if (this.deltas == null) {
                    this.deltas = new ArrayList<>();
                }
                Boolean flag = true;
                for (UnderlyerValue deltaValue : this.deltas) {
                    if (underlyerValue.getUnderlyerId().equals(deltaValue.getUnderlyerId())) {
                        deltaValue.merge(underlyerValue);
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    UnderlyerValue deltaValue = new UnderlyerValue();
                    deltaValue.setUnderlyerId(underlyerValue.getUnderlyerId());
                    deltaValue.merge(underlyerValue);
                    this.deltas.add(deltaValue);
                }
            }
        }
        List<UnderlyerValue> vegas = contract.getVegas();
        if (vegas != null && vegas.size() > 0) {
            for (UnderlyerValue underlyerValue : vegas) {
                if (this.vegas == null) {
                    this.vegas = new ArrayList<>();
                }
                Boolean flag = true;
                for (UnderlyerValue vegaValue : this.vegas) {
                    if (underlyerValue.getUnderlyerId().equals(vegaValue.getUnderlyerId())) {
                        vegaValue.merge(underlyerValue);
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    UnderlyerValue vegaValue = new UnderlyerValue();
                    vegaValue.setUnderlyerId(underlyerValue.getUnderlyerId());
                    vegaValue.merge(underlyerValue);
                    this.vegas.add(vegaValue);
                }
            }
        }

        RectangularCoordinates gammas = contract.getGammas();
        if (gammas != null) {
            if (this.gammas == null) {
                this.gammas = new RectangularCoordinates();
            }
            this.gammas.merge(gammas);
        }

        RectangularCoordinates vannas = contract.getVannas();
        if (vannas != null) {
            if (this.vannas == null) {
                this.vannas = new RectangularCoordinates();
            }
            this.vannas.merge(vannas);
        }

        RectangularCoordinates volgas = contract.getVolgas();
        if (volgas != null) {
            if (this.volgas == null) {
                this.volgas = new RectangularCoordinates();
            }
            this.volgas.merge(volgas);
        }
    }
}
